package org.itboys.ace.web.lasted.process;

import org.itboys.admin.entity.lasted.process.SystemProcess;
import org.itboys.admin.entity.lasted.process.SystemProcessDetail;
import org.itboys.admin.service.lasted.process.SystemProcessDetailService;
import org.itboys.admin.service.lasted.process.SystemProcessService;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *作者：江雄
 * 描述：系统-流程（审核）
 * 时间：2017年2月24日.重新构建
 * 描述：系统_流程（审核）_controller
 */
@RestController
@RequestMapping("/ace/system/process")
public class AceSystemProcessController extends BaseController{
    @Autowired
    private SystemProcessService processService;
    @Autowired
    private SystemProcessDetailService processDetailService;

    /**
     * 审核流程-列表页
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/process-list")
    public ModelAndView paramTemplateList(HttpServletRequest request, HttpServletResponse response, Model model) {
        return new ModelAndView("/ace/sys/process/process-list");
    }

    /**
     * 分页查询流程
     * @param request
     * @param response
     */
    @RequestMapping("/select")
    public void select(HttpServletRequest request, HttpServletResponse response){

            PageResult<SystemProcess> result=processService.selectProcess(request);
            JsonPageUtils.renderJsonPage(result.getTotal(),result.getData(),response);

    }
    /**
     * 分页查询当前流程
     * @param request
     * @param response
     */
    @RequestMapping("/selectCurrent")
    public void selectCurrent(HttpServletRequest request, HttpServletResponse response){

        PageResult<SystemProcess> result=processService.selectProcessCurrent(request);
        JsonPageUtils.renderJsonPage(result.getTotal(),result.getData(),response);

    }
    /**
     * 分页查询流程明细
     * @param request
     * @param response
     */
    @RequestMapping("/detail/select")
    public void selectDetail(HttpServletRequest request, HttpServletResponse response){
        PageResult<SystemProcessDetail> result=processDetailService.select(request);
       // logger.info("total======"+result.getTotal());
        //logger.info("data======"+result.getData().size());
        JsonPageUtils.renderJsonPage(result.getTotal(),result.getData(),response);

    }

    /**
     * 流程明细主页，主要是附属在具体业务下
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/detail/detail-list")
    public ModelAndView detailList(HttpServletRequest request, HttpServletResponse response, Model model,
                                   @RequestParam(value ="outClassId",required = true)Long outClassId,
                                   @RequestParam(value ="outClassName",required = true)String outClassName) {
        model.addAttribute("outClassId",outClassId);
        model.addAttribute("outClassName",outClassName);

        return new ModelAndView("/ace/sys/process/detail-list");
    }



}
